package com.uxwine.alarm.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBAlarm extends SQLiteOpenHelper
{
	private static final String DB_NAME = "alarms.db";
	private static final int DB_VERSION = 6;
	
	public DBAlarm(Context context)
	{
		super(context, DB_NAME, null, DB_VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db)
	{
		db.execSQL("CREATE TABLE IF NOT EXISTS " + TBAlram.TB_NAME + TBAlram.TABLE_DEFINE + ";");
		//defaultInsert(db);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		if(oldVersion < newVersion)
		{
			db.execSQL("DROP TABLE IF EXISTS " + TBAlram.TB_NAME);
            onCreate(db);
		}			
	}
	
	private void defaultInsert(SQLiteDatabase db)
	{
		String insertMe = "INSERT INTO " + TBAlram.TB_NAME + TBAlram.TABLE_INSERT_ALL;
        db.execSQL(insertMe + " VALUES(0, '0:0:0:0:0:0:0:0:0:0', 1, 0, 1, '', '');");
        db.execSQL(insertMe + " VALUES(0, '0:0:0:0:0:0:0:0:0:0', 1, 0, 1, '', '');");
	}

}
